package vip.xiaonuo.sys.fymodule.thirdpa.api.impl;

import com.alibaba.fastjson.JSONObject;
import vip.xiaonuo.sys.config.TaskExecutePoolConfig;
import vip.xiaonuo.sys.core.util.PaPayUtil;
import vip.xiaonuo.sys.fymodule.account.service.ISxoSafetyLogService;
import vip.xiaonuo.sys.fymodule.thirdpa.api.BaseClient;

/**
 * 查询银行费用扣收结果(KFEJZB6109)
 */
public class BankCostDsDealResultQueryApi extends BaseClient {

    private final ISxoSafetyLogService sxoSafetyLogService;
    private final TaskExecutePoolConfig taskExecutePoolConfig;


    public BankCostDsDealResultQueryApi(ISxoSafetyLogService sxoSafetyLogService, TaskExecutePoolConfig taskExecutePoolConfig) {
        this.sxoSafetyLogService = sxoSafetyLogService;
        this.taskExecutePoolConfig = taskExecutePoolConfig;
    }

    @Override
    public String getApiUrl() {
        return PaPayUtil.BANK_COST_DS_DEAL_RESULT_QUERY;
    }

    @Override
    public void saveResult(String logId, String result) {
        taskExecutePoolConfig.getAsyncExecutor().execute(() -> {
            sxoSafetyLogService.updateSafetyLog(logId, result);
        });
    }

    @Override
    public String saveLog(JSONObject params) {
        String busId = params.getString("FundSummaryAcctNo");
        return sxoSafetyLogService.saveSafetyLog("", busId, PaPayUtil.BANK_COST_DS_DEAL_RESULT_QUERY, params.toJSONString());
    }

}
